<template><div><h2 id="列过滤器" tabindex="-1"><a class="header-anchor" href="#列过滤器"><span>列过滤器</span></a></h2>
<p>这个功能可以给表格的列设置一个过滤器，可以更方便的根据这一列进行数据表格过滤操作</p>
<p><img src="@source/dcat-admin-2x/assets/images/3e9a5270-4c98-448e-ad08-133edff87fcb-e9lGafiNZx.png" alt=""></p>
<h2 id="字符串比较查询" tabindex="-1"><a class="header-anchor" href="#字符串比较查询"><span>字符串比较查询</span></a></h2>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// WHERE `username` = "$input"</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">username</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Equal</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的调用可以给 <code v-pre>username</code> 这一列的头部加上一个 <code v-pre>input</code> 类型的过滤器，点击过滤器图标展开过滤器，输入查询提交后，会对这一列执行 <code v-pre>等于</code> 查询。</p>
<h3 id="开启字段值查询" tabindex="-1"><a class="header-anchor" href="#开启字段值查询"><span>开启字段值查询</span></a></h3>
<p>这个功能可以给每一列字段的值设置一个过滤器，点击该列字段的值就可以进行数据表格过滤操作，非常方便。</p>
<blockquote>
<p>开启此功能之后会把这个字段的原始值作为搜索内容，不会受 <code v-pre>display</code> 方法影响。</p>
</blockquote>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 设置为 label 或调用 display 方法不会影响查询内容</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">ip</span><span class="token operator">-></span><span class="token function">label</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 相当于</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">ip</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Equal</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">valueFilter</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>鼠标移动到开启了值查询功能的列上面，右边会显示一个<code v-pre>放大镜</code>图标<br>
<img src="@source/dcat-admin-2x/assets/images/fbabbe56-8398-455f-b9f9-d9645ddeb1e3-D6JhADBXpz.png" alt=""></p>
<p>点击列之后，表头会出现<code v-pre>重置</code>按钮，点击可以取消筛选</p>
<p><img src="@source/dcat-admin-2x/assets/images/2e92e9e6-0353-4c14-9475-42e90ae6f969-b3wWxGGZbh.png" alt=""></p>
<h4 id="设置值的字段名称" tabindex="-1"><a class="header-anchor" href="#设置值的字段名称"><span>设置值的字段名称</span></a></h4>
<p>如果当前列的值并非用户想要搜索的值，可以通过以下方法更改字段名称。</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">model</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">with</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 实际搜索的会是 name 字段的值</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">username</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'name'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 二维数组</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">user_id</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'user.id'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 闭包</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">user_id</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token property">user</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'id'</span><span class="token punctuation">]</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="隐藏表头的筛选器图标" tabindex="-1"><a class="header-anchor" href="#隐藏表头的筛选器图标"><span>隐藏表头的筛选器图标</span></a></h4>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">user_id</span><span class="token operator">-></span><span class="token function">filterByValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 相当于</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">user_id</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Equal</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">valueFilter</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">        <span class="token operator">-></span><span class="token function">hide</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>效果如下<br>
<img src="@source/dcat-admin-2x/assets/images/0a4da1d4-c9c0-4d4f-8212-abc621872e61-y1U1msNuGL.png" alt=""></p>
<h3 id="其余input表单类型过滤器" tabindex="-1"><a class="header-anchor" href="#其余input表单类型过滤器"><span>其余Input表单类型过滤器</span></a></h3>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// WHERE `username` LIKE "%{$input}%"</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">username</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Like</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// WHERE `username` LIKE "{$input}%"</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">username</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>StartWith</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// WHERE `username` > "$input"</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">username</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Gt</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// WHERE `username` &lt;= "$input"</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">username</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Ngt</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// WHERE `username` &lt; "$input"</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">username</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Lt</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// WHERE `username` >= "$input"</span></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token property">username</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Nlt</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="时间日期" tabindex="-1"><a class="header-anchor" href="#时间日期"><span>时间日期</span></a></h3>
<p>如果字段是时间、日期相关的字段，可以使用下面的方法</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Equal</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">date</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">time</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Like</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">time</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">datetime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Gt</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">datetime</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'YYYY-MM-DD HH:mm:ss'</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="多选查询" tabindex="-1"><a class="header-anchor" href="#多选查询"><span>多选查询</span></a></h2>
<p>假设需要在表格数据中通过 <code v-pre>status</code> 字段过滤一个或者多个状态的数据，使用多选过滤可以非常方便的实现</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'status'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'状态'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>In</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">[</span></span>
<span class="line">        <span class="token number">0</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'未知'</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token number">1</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'已下单'</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token number">2</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'已付款'</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token number">3</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'已取消'</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="范围查询" tabindex="-1"><a class="header-anchor" href="#范围查询"><span>范围查询</span></a></h2>
<p>假设需要通过 <code v-pre>price</code> 字段过滤出某个价格范围内的数据</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'price'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Between</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>或者是时间、日期范围的过滤</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Dcat<span class="token punctuation">\</span>Admin<span class="token punctuation">\</span>Grid</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Between</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">date</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">time</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Between</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">time</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">datetime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Between</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">datetime</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="指定查询字段名" tabindex="-1"><a class="header-anchor" href="#指定查询字段名"><span>指定查询字段名</span></a></h2>
<p>通过<code v-pre>setColumnName</code>方法可以指定查询字段的名称</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'column'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Equal</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">setColumnName</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'custom_column'</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="查询json字段" tabindex="-1"><a class="header-anchor" href="#查询json字段"><span>查询json字段</span></a></h3>
<blockquote>
<p>Since <code v-pre>v1.7.0</code></p>
</blockquote>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'column'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Equal</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">setColumnName</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'json_column->label'</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="关联关系字段查询" tabindex="-1"><a class="header-anchor" href="#关联关系字段查询"><span>关联关系字段查询</span></a></h3>
<blockquote>
<p>Since <code v-pre>v1.7.0</code></p>
</blockquote>
<p>如果安装了 <a href="https://github.com/jqhph/laravel-wherehasin" target="_blank" rel="noopener noreferrer">dcat/laravel-wherehasin</a>，则会优先使用<code v-pre>whereHasIn</code>方法进行查询操作</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'user.name'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Equal</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token variable">$grid</span><span class="token operator">-></span><span class="token function">column</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'user_name'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">filter</span><span class="token punctuation">(</span></span>
<span class="line">    <span class="token class-name class-name-fully-qualified static-context">Grid<span class="token punctuation">\</span>Column<span class="token punctuation">\</span>Filter<span class="token punctuation">\</span>Equal</span><span class="token operator">::</span><span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">setColumnName</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'user.name'</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></div></template>


